package org.miaosha.service;

import org.miaosha.model.Goods;
import org.miaosha.model.GoodsInfoView;
import org.miaosha.model.MiaoshaUser;
import org.miaosha.model.OrderInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Wrb
 * @date 2019/7/26 17:34
 */
@Service
public class MiaoshaService {

	@Autowired
	private GoodsService goodsService;

	@Autowired
	private OrderService orderService;

	public OrderInfo miaosha(MiaoshaUser user, GoodsInfoView goods) {
		//减库存 下订单 写入秒杀订单

		goodsService.reduceStock(goods);

		return orderService.createOrder(user, goods);
	}
}
